package com.zzz.treecomponent.config;

import com.zzz.treecomponent.properties.PreTreeProperties;
import com.zzz.treecomponent.util.PrefixTree;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties({PreTreeProperties.class})
public class PrefixTreeConfig {

    @Bean
    PrefixTree prefixTree(PreTreeProperties preTreeProperties) {
        PrefixTree prefixTree = new PrefixTree();
        prefixTree.init(preTreeProperties.getFilterString().toArray(new String[preTreeProperties.getFilterString().size()]));
        prefixTree.setReplace(preTreeProperties.getReplace());
        return prefixTree;
    }


}
